import {
	$post
} from '@/puigins/request.js'
import jsCookie from 'js-cookie'
export default {
	refreshUser({
		state
	}, callback) {
		let openId = jsCookie.get('qq_openId')
		let accessToken = jsCookie.get('qq_accessToken')
		console.log("!openId || !accessToken",!openId || !accessToken)
		if (!openId || !accessToken) {
			return
		}
		let data = {
			openId,
			accessToken
		}

		$post('/user/qqLogin', data).then(res => {
			if (res.code == 200) {
				state.user = res.data
				jsCookie.remove('qq_openId')
				jsCookie.remove('qq_accessToken')
				callback(res.data)
			}
		})

	}
}
